package com.noble.glamour.ui.fragment.video;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.noble.glamour.R;
import com.noble.library.view.base.BasePanel;

import java.util.ArrayList;
import java.util.List;

/**
 * 视频集：管理视频
 * Created by Su on 2017/11/14.
 */
public class VideoManagePanel extends BasePanel {
    private RecyclerView recyclerView;
    private VideoMgrAdapter adapter;

    public VideoManagePanel(Context context) {
        super(context);
        setContentView(R.layout.video_manage_panel);
        initView();
    }

    private void initView() {
        recyclerView = (RecyclerView) findViewById(R.id.video_list);
        recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
        recyclerView.addItemDecoration(new ItemSpaces());
        adapter = new VideoMgrAdapter(getActivity());
        recyclerView.setAdapter(adapter);

        // TODO test
        List<String> dataList = new ArrayList<>();
        dataList.add("1");
        dataList.add("2");
        dataList.add("3");
        dataList.add("4");
        dataList.add("5");
        dataList.add("6");
        dataList.add("7");
        dataList.add("8");
        dataList.add("9");
        dataList.add("0");
        dataList.add("10");
        adapter.setList(dataList);
    }

    private class ItemSpaces extends RecyclerView.ItemDecoration {
        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            super.getItemOffsets(outRect, view, parent, state);
            outRect.left = 25;
            outRect.right = 25;
            outRect.top = 25;
        }
    }
}
